package com.rj.core.domain;

import com.rj.core.check.Dict;
import com.rj.core.check.AssertorBean;
import com.rj.core.check.DictList;
import com.rj.core.type.BeanType;
import com.rj.core.type.BeanTypeHelper;
import com.rj.util.AssertBeanUtils;

/**
 * 数据处理Map
 *
 * @author YFX_RANLUBO
 * @date 2022/10/20 17:11
 **/
public class BeanDomain extends Domain {
    public final static BeanType<String> title = BeanTypeHelper.of("title", "标题", false, 20);
    public final static BeanType<String> type = new BeanType<String>("type", "类型").setDict(DictList.of(
            Dict.of("0", "a1", (e) -> ((AssertorBean<BeanDomain>) e).field(BeanDomain::getAge, "年龄", false).between(0, 12)),
            Dict.of("1", "a2", (e) -> ((AssertorBean<BeanDomain>) e).field(BeanDomain::getAge, "年龄", false).between(13, 18))));
    public final static BeanType<Double> age = BeanTypeHelper.of("age", "年龄", false);
    public final static BeanType<String> je = BeanTypeHelper.of("je", "金额");

    public final static BeanType<String> je1 = BeanTypeHelper.of("je1", "金额");

    public String getTitle() {
        return get(title);
    }

    public void setTitle(String value) {
        set(title, value);
    }

    public String getType() {
        return get(type);
    }

    public void setType(String value) {
        set(type, value);
    }

    public Integer getAge() {
        return get(age);
    }

    public void setAge(Integer value) {
        set(age, value);
    }

    public String getJe() {
        return get(je);

    }

    public void setJe(String value) {
        set(je, value);
    }

    @Override
    public void doneCheck() {
        AssertBeanUtils.check(getType(), type).in(type.getDict());
    }
}
